<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\AdminOperationLog
 *
 * @property int $id
 * @property int $admin_id 管理員ID
 * @property int $staff_id 工號
 * @property string $admin_name 管理員
 * @property string $route_name 路由名
 * @property string $route_permission 權限名
 * @property string $method 請求方法
 * @property string $uri URI
 * @property string $url URL
 * @property string $full_url 完整URL
 * @property string $ip IP
 * @property string $session_id 會話ID
 * @property array|null $query 請求參數
 * @property string $user_agent 瀏覽器信息
 * @property \Illuminate\Support\Carbon $operated_at 操作時間
 * @property-read \App\Models\AdminUser $admin
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog whereAdminId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog whereAdminName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog whereFullUrl($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog whereIp($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog whereMethod($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog whereOperatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog whereQuery($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog whereRouteName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog whereRoutePermission($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog whereSessionId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog whereStaffId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog whereUri($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog whereUrl($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminOperationLog whereUserAgent($value)
 * @mixin \Eloquent
 */
class AdminOperationLog extends Model
{
    protected $fillable = [
        'admin_id',
        'admin_name',
        'staff_id',
        'route_name',
        'route_permission',
        'method',
        'uri',
        'url',
        'full_url',
        'ip',
        'session_id',
        'query',
        'user_agent',
        'operated_at'
    ];
    protected $dates = [
        'operated_at',
        'created_at',
        'updated_at',
    ];
    protected $casts    = [
        'query' => 'array',
    ];
    public $timestamps = false;

    public function admin()
    {
        return $this->belongsTo(AdminUser::class, 'admin_id', 'id');
    }
}
